#COMAKE2 edit-mode: -*- Makefile -*-
####################64Bit Mode####################
ifeq ($(shell uname -m),x86_64)
CC=gcc
CXX=g++
CXXFLAGS=-g \
  -pipe \
  -W \
  -Wall \
  -fPIC
CFLAGS=-g \
  -pipe \
  -W \
  -Wall \
  -fPIC
CPPFLAGS=-Dprivate=public \
  -D_GNU_SOURCE \
  -D__STDC_LIMIT_MACROS \
  -DVERSION=\"1.9.8.7\"
INCPATH=-I. \
  -I./include \
  -I../include \
  -I./output \
  -I./output/include
DEP_INCPATH=-I../baidu_lib/lib2-64/bsl \
  -I../baidu_lib/lib2-64/bsl/include \
  -I../baidu_lib/lib2-64/bsl/output \
  -I../baidu_lib/lib2-64/bsl/output/include \
  -I../baidu_lib/lib2-64/ullib \
  -I../baidu_lib/lib2-64/ullib/include \
  -I../baidu_lib/lib2-64/ullib/output \
  -I../baidu_lib/lib2-64/ullib/output/include \
  -I../baidu_lib/third-64/boost \
  -I../baidu_lib/third-64/boost/include \
  -I../baidu_lib/third-64/boost/output \
  -I../baidu_lib/third-64/boost/output/include \
  -I../baidu_lib/third-64/gtest \
  -I../baidu_lib/third-64/gtest/include \
  -I../baidu_lib/third-64/gtest/output \
  -I../baidu_lib/third-64/gtest/output/include

#============ CCP vars ============
CCHECK=@ccheck.py
CCHECK_FLAGS=
PCLINT=@pclint
PCLINT_FLAGS=
CCP=@ccp.py
CCP_FLAGS=


#COMAKE UUID
COMAKE_MD5=2e61ffc10c5e24316e8971f136ffe39c  COMAKE


.PHONY:all
all:comake2_makefile_check test 
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mall[0m']"
	@echo "make all done"

.PHONY:comake2_makefile_check
comake2_makefile_check:
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mcomake2_makefile_check[0m']"
	#in case of error, update 'Makefile' by 'comake2'
	@echo "$(COMAKE_MD5)">comake2.md5
	@md5sum -c --status comake2.md5
	@rm -f comake2.md5

.PHONY:ccpclean
ccpclean:
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mccpclean[0m']"
	@echo "make ccpclean done"

.PHONY:clean
clean:ccpclean
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mclean[0m']"
	rm -rf test
	rm -rf ./output/bin/test
	rm -rf ../bloom_filter/test_bloom_filter.o
	rm -rf ../big_map/test_disk_matrix.o
	rm -rf ../big_map/test_item.o
	rm -rf ../big_map/test_mem_matrix.o
	rm -rf ../hash_func/test_hash_func.o
	rm -rf test_test_mem_matrix.o

.PHONY:dist
dist:
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mdist[0m']"
	tar czvf output.tar.gz output
	@echo "make dist done"

.PHONY:distclean
distclean:clean
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mdistclean[0m']"
	rm -f output.tar.gz
	@echo "make distclean done"

.PHONY:love
love:
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mlove[0m']"
	@echo "make love done"

test:../bloom_filter/test_bloom_filter.o \
  ../big_map/test_disk_matrix.o \
  ../big_map/test_item.o \
  ../big_map/test_mem_matrix.o \
  ../hash_func/test_hash_func.o \
  test_test_mem_matrix.o
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mtest[0m']"
	$(CXX) ../bloom_filter/test_bloom_filter.o \
  ../big_map/test_disk_matrix.o \
  ../big_map/test_item.o \
  ../big_map/test_mem_matrix.o \
  ../hash_func/test_hash_func.o \
  test_test_mem_matrix.o -Xlinker "-("  ../baidu_lib/lib2-64/bsl/lib/libbsl.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_ResourcePool.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_archive.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_buffer.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_check_cast.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_exception.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_pool.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_utils.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_var.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_var_implement.a \
  ../baidu_lib/lib2-64/bsl/lib/libbsl_var_utils.a \
  ../baidu_lib/lib2-64/ullib/lib/libullib.a \
  ../baidu_lib/third-64/boost/lib/libboost_chrono.a \
  ../baidu_lib/third-64/boost/lib/libboost_date_time.a \
  ../baidu_lib/third-64/boost/lib/libboost_exception.a \
  ../baidu_lib/third-64/boost/lib/libboost_filesystem.a \
  ../baidu_lib/third-64/boost/lib/libboost_graph.a \
  ../baidu_lib/third-64/boost/lib/libboost_locale.a \
  ../baidu_lib/third-64/boost/lib/libboost_math_c99.a \
  ../baidu_lib/third-64/boost/lib/libboost_math_c99f.a \
  ../baidu_lib/third-64/boost/lib/libboost_math_c99l.a \
  ../baidu_lib/third-64/boost/lib/libboost_math_tr1.a \
  ../baidu_lib/third-64/boost/lib/libboost_math_tr1f.a \
  ../baidu_lib/third-64/boost/lib/libboost_math_tr1l.a \
  ../baidu_lib/third-64/boost/lib/libboost_prg_exec_monitor.a \
  ../baidu_lib/third-64/boost/lib/libboost_program_options.a \
  ../baidu_lib/third-64/boost/lib/libboost_python.a \
  ../baidu_lib/third-64/boost/lib/libboost_random.a \
  ../baidu_lib/third-64/boost/lib/libboost_regex.a \
  ../baidu_lib/third-64/boost/lib/libboost_serialization.a \
  ../baidu_lib/third-64/boost/lib/libboost_signals.a \
  ../baidu_lib/third-64/boost/lib/libboost_system.a \
  ../baidu_lib/third-64/boost/lib/libboost_test_exec_monitor.a \
  ../baidu_lib/third-64/boost/lib/libboost_thread.a \
  ../baidu_lib/third-64/boost/lib/libboost_timer.a \
  ../baidu_lib/third-64/boost/lib/libboost_unit_test_framework.a \
  ../baidu_lib/third-64/boost/lib/libboost_wave.a \
  ../baidu_lib/third-64/boost/lib/libboost_wserialization.a \
  ../baidu_lib/third-64/gtest/lib/libgtest.a \
  ../baidu_lib/third-64/gtest/lib/libgtest_main.a -lpthread \
  -lcrypto \
  -lrt -Xlinker "-)" -o test
	mkdir -p ./output/bin
	cp -f --link test ./output/bin

../bloom_filter/test_bloom_filter.o:../bloom_filter/bloom_filter.cpp
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40m../bloom_filter/test_bloom_filter.o[0m']"
	$(CXX) -c $(INCPATH) $(DEP_INCPATH) $(CPPFLAGS) $(CXXFLAGS)  -o ../bloom_filter/test_bloom_filter.o ../bloom_filter/bloom_filter.cpp

../big_map/test_disk_matrix.o:../big_map/disk_matrix.cpp
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40m../big_map/test_disk_matrix.o[0m']"
	$(CXX) -c $(INCPATH) $(DEP_INCPATH) $(CPPFLAGS) $(CXXFLAGS)  -o ../big_map/test_disk_matrix.o ../big_map/disk_matrix.cpp

../big_map/test_item.o:../big_map/item.cpp
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40m../big_map/test_item.o[0m']"
	$(CXX) -c $(INCPATH) $(DEP_INCPATH) $(CPPFLAGS) $(CXXFLAGS)  -o ../big_map/test_item.o ../big_map/item.cpp

../big_map/test_mem_matrix.o:../big_map/mem_matrix.cpp
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40m../big_map/test_mem_matrix.o[0m']"
	$(CXX) -c $(INCPATH) $(DEP_INCPATH) $(CPPFLAGS) $(CXXFLAGS)  -o ../big_map/test_mem_matrix.o ../big_map/mem_matrix.cpp

../hash_func/test_hash_func.o:../hash_func/hash_func.cpp
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40m../hash_func/test_hash_func.o[0m']"
	$(CXX) -c $(INCPATH) $(DEP_INCPATH) $(CPPFLAGS) $(CXXFLAGS)  -o ../hash_func/test_hash_func.o ../hash_func/hash_func.cpp

test_test_mem_matrix.o:test_mem_matrix.cpp
	@echo "[[1;32;40mCOMAKE:BUILD[0m][Target:'[1;32;40mtest_test_mem_matrix.o[0m']"
	$(CXX) -c $(INCPATH) $(DEP_INCPATH) $(CPPFLAGS) $(CXXFLAGS)  -o test_test_mem_matrix.o test_mem_matrix.cpp

endif #ifeq ($(shell uname -m),x86_64)


